<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="padding-top:25px">
        <a class="aui-pull-left" onclick="openManagePage()" style="font-size:31px;line-height:25px">...</a>
        <div class="aui-title">客旺旺</div>
        <a class="aui-pull-right" onclick="logout()">退出</a>
    </header>

    <script type="text/javascript">
        apiready = function() {

            var ajpush = api.require('ajpush');

            //透传消息
            if (api.systemType == 'android') {
                var ajpush = api.require('ajpush');
                ajpush.init(function(ret) {
                    if (ret && ret.status) {

                        ajpush.setListener(function(ret) {
                            var mp3 = 'widget://order.mp3'

                            if(ret.extra.type == 'pay'){
                                var mp3 = 'widget://pay.mp3'
                            }
                            var audio = api.require('audio');
                            audio.play({
                                path: mp3
                            });
                        });

                    }
                });
            }

            api.openFrame({
                name: 'main_content',
                url: './main_content.html',
                rect: {
                    x: 0,
                    y: 70,
                    w: 'auto',
                    h: 'auto'
                }
            });

            api.addEventListener({
                name: 'keyback'
            }, function(ret, err) {
                api.toLauncher();
                return false;
            });
        }

        function openManagePage() {
            api.openWin({
                name: 'manage',
                url: './manage.html'
            });
        }

        function logout() {
            api.removePrefs({
                key: 'user'
            });
            api.openWin({
                name: 'login',
                url: 'login.html',
                slidBackEnabled: false
            });
            setTimeout(function() {
                api.closeWin();
            }, 1000)
        }
    </script>
</body>

</html>
